package top.zhangjianyong.blog.portal.controller;

import java.lang.reflect.InvocationTargetException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.blog.params.weibo.WeiboPageParam;
import top.zhangjianyong.blog.response.ApiResponse;
import top.zhangjianyong.blog.service.WeiboService;

/**
 * @author zhangjianyong
 * @since 2025/5/18 12:20
 */
@RequestMapping("/portal/weibo")
@RestController("portalWeiboController")
public class WeiboController {

  private final WeiboService weiboService;

  public WeiboController(WeiboService weiboService) {
    this.weiboService = weiboService;
  }

  @PostMapping("/page")
  public ApiResponse page(@RequestBody @Validated WeiboPageParam param)
      throws InvocationTargetException,
          InstantiationException,
          IllegalAccessException,
          NoSuchMethodException {
    return weiboService.portalPage(param);
  }

  @PostMapping("/top/list")
  public ApiResponse topList() {
    return weiboService.topList();
  }
}
